package com.qf.mvc2203.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.qf.mvc2203.utils.MySerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    @JsonProperty("new_id")
    private Integer id;
    @JsonIgnore
    private String name;
    private Boolean gender;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") // 格式化json字符串时该注解生效
    private Date birth;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String[] hobby;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<String> hobby1 = new ArrayList<>();

    @JsonSerialize(using = MySerializer.class)  // 自定义序列号器
    private Double salary = 10000.126;

}
